package com.es.demo;

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;

/**
 * @author 许路路
 */
public class ElasticSearchDemo {

    private static Logger logger = LoggerFactory.getLogger(ElasticSearchDemo.class);

    public static void main(String[] args) {

        //创建客户端
        TransportClient client = null;
        try {
            client = new PreBuiltTransportClient(Settings.EMPTY).addTransportAddresses(
                    new InetSocketTransportAddress(InetAddress.getByName(HOST), PORT));
        } catch (Exception e) {
            e.printStackTrace();
        }

        logger.debug("Elasticsearch connect info:" + client);

        //关闭客户端
        client.close();
    }

    public final static String HOST = "192.168.2.61";

    public final static int PORT = 9300;//http请求的端口是9200，客户端是9300


}
